<template>
	<view class="content">
		<view>
			<uni-breadcrumb separator=">">
				<uni-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to">
					{{route.name}}
				</uni-breadcrumb-item>
			</uni-breadcrumb>
		</view>
		<hr>
		<view style="{display: flex;flex-direction: column;}">
			<view class="input-group">
				<input v-model="phone1" class="input" type="safe-password" placeholder="请输入手机号码" />
				<view style="width: 100%;">
					<input v-model="phone2" type="safe-password" placeholder="请输入短信验证码" class="input"></input>
					<button  style="display: block;width: 40%;height: 40%; vertical-align: middle;line-height: initial;" class="send" plain="true" size="mini" :disabled="disabled" @click="sendCode">{{codeMsg}}</button>
				</view>

				<button class="btn" @click="next">下一步</button>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		name: "uni-stat-breadcrumb",
		data() {
			return {
				phone1: '',
				phone2: '',
				codeNum: 60,
				// 显示的文本
				codeMsg: "",
				// 按钮是否禁用
				disabled: false,
				routes: [{
						to: "/pages/login/forgetpwd/forgetpwd",
						name: "1验证手机号码",
					},
					{
						name: "2设置新密码",
					},

				],
			};
		},
		onReady() {
			this.codeMsg = '获取验证码';
		},
		methods: {
			sendCode() {
				this.disabled = true;
				let timer = setInterval(() => {
					--this.codeNum;
					this.codeMsg = '重新发送(' + this.codeNum + ')';
				}, 1000);
				setTimeout(() => {
					clearInterval(timer);
					this.codeNum = 60;
					this.disabled = false;
					this.codeMsg = '重新发送';
				}, 60000)
			},

			next() {
				uni.navigateTo({
					url: "/pages/login/forgetpwd/setnewpwd"
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.input-group {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin: 0 $uni-spacing-row-lg;
		.input {
			border: 1px solid $uni-border-color;
			border-top: none;
			border-left: none;
			border-right: none;
			border-radius: $uni-border-radius-base;
			width: 100%;
			height: $uni-font-size-lg * 3;
			color: #000;
		}

		.btn {
			margin: $uni-spacing-col-lg*2.5 $uni-spacing-row-lg*1.5 0;
			background: blue;
			color: $uni-text-color-inverse;

			&:active {
				background-color: darken(blue, 5%);
			}

			width: 100%;
		}
	}
</style>
